package ro.peoplecentric.ctc.common.service;

import java.util.List;
import ro.peoplecentric.ctc.common.entity.Item;
import ro.peoplecentric.ctc.common.exception.ApplicationException;
import ro.peoplecentric.ctc.common.util.ui.ItemCriteria;

/**
 * Service for Item CRUD.
 * 
 * @author pguzun
 */
public interface ItemService {

	/**
	 * Saves the {@link Item} to DB. If the provided {@link Item} object was
	 * already associated with the persistent context, the entity's state will
	 * be updated.
	 * 
	 * @param item
	 *            the {@link Item} to save
	 * @throws ApplicationException
	 *             in case of DAO exception
	 */
	void saveItem(Item item) throws ApplicationException;

	/**
	 * Deletes an existing {@link Item} from the data store.
	 * 
	 * @param item
	 *            the <strong>persistent</strong> {@link Item} to delete
	 * @throws ApplicationException
	 *             in case of DAO exception
	 */
	void deleteItem(Item currentObject) throws ApplicationException;

	/**
	 * Gets all the {@link Item}s from DB.
	 * 
	 * @return a list of {@link Item}s
	 * @throws ApplicationException
	 *             in case of DAO exception
	 */
	List<Item> getAll() throws ApplicationException;

	/**
	 * Gets the last modified {@link Item}s from DB.
	 * 
	 * @return a list of {@link Item}s last modified
	 * @throws ApplicationException
	 *             in case of DAO exception
	 */
	List<Item> getLastModifiedItems() throws ApplicationException;

	/**
	 * Find {@link Item}s from DB.
	 * 
	 * @param itemCriteria
	 *            the item criteria to search by
	 * @return a list of found {@link Item}s
	 * @throws ApplicationException
	 *             in case of DAO exception
	 */
	List<Item> find(ItemCriteria itemCriteria) throws ApplicationException;

	/**
	 * Get {@link Item} by id.
	 * 
	 * @param id
	 *            the item ID
	 * @return the fount {@link Item} entity or null if not found.
	 */
	Item getById(Long id) throws ApplicationException;

	/**
     * Find all {@link Item items} sorted by column and sense
     *
     * @author Danut Chindris
     * @since October 11, 2013
     * @param order the sense used for sorting
     * @param orderBy the column used for sorting
     * @return list of found {@link Item items}
     */
	List<Item> getAllItems(String order, String orderBy) throws ApplicationException;
}
